/**
 * @author LKQ
 * @date 2022/1/31 15:11
 * @description 一趟遍历
 */
public class Solution {
    public static void main(String[] args) {
        Solution solution = new Solution();
        int[] nums = {1, 2, 2, 3};
        solution.isMonotonic(nums);
    }
    public boolean isMonotonic(int[] nums) {
        boolean increase = true, decrease = true;
        for (int i = 1; i < nums.length; i++) {
            if (nums[i] > nums[i - 1]) {
                decrease = false;
            }
            if (nums[i] < nums[i - 1]) {
                increase = false;
            }
        }
        return increase || decrease;
    }
}
